﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
using ExpenseTracker.Entity;

namespace ExpenseTracker.DataAccess
{
    public class BaseDb : IDisposable
    {
        private ExpenseTracker.Entity.Account _account = null;
        private SQLiteConnection _connection = null;

        public BaseDb(ExpenseTracker.Entity.Account account)
        {
            _account = account;
            _connection = new SQLiteConnection("Provider=System.Data.SQLite;Data Source=" + _account.DatabaseFilePath);
            _connection.Open();
        }

        void System.IDisposable.Dispose()
        {
            _connection.Close();
            _connection.Dispose();
            GC.SuppressFinalize(this);
        }

        protected ExpenseTracker.Entity.Account Account
        {
            get { return _account; }
        }

        protected SQLiteConnection Connection
        {
            get { return _connection; }
        }
    }
}
